For this scenario, assume that a report has been created and it does not contain any groups. To add a new group to the report at runtime, you can use code similar to the following:
Note: Please note that using this method will not display the group name on the report.
You can place this code in the General Declarations section.
Dim CRXReport As New CrystalReport1 'The existing report (ActiveX Designer) Dim CRXDBField As CRAXDRT.DatabaseFieldDefinition
You can place this code in the FORM_LOAD event procedure.
Private Sub Form_Load()
For this example, you want to add a group that is based on the REGION field. This code accesses the first table to get the 12th field, which is the REGION field.
set CRXDBField = CRXReport.Database.Tables.Item(1).Fields.Item(12)
Now you can add the new group to the report. Please note that:
CRXReport.AddGroup 0, CRXDBField, crGCAnyValue, crAscendingOrder
CRViewer1.ReportSource = CRXReport CRViewer1.ViewReport End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |